<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>角色管理</title>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
</head>
<body>

<div style="margin: 20px">
    <form class="layui-form layui-form-pane">
        <input type="hidden" id="id" name="id" th:value="${r.id}">
        <div class="layui-form-item">
            <label class="layui-form-label">角色名称</label>
            <div class="layui-input-block">
                <input class="layui-input" th:value="${r.name}" name="name" placeholder="输入角色名称" autocomplete="off"/>
            </div>
        </div>
        <!---->
        <div class="layui-form-item">
            <label class="layui-form-label">角色说明</label>
            <div class="layui-input-block">
                <input class="layui-input" th:value="${r.content}" readonly  name="content" placeholder="输入角色说明" autocomplete="off"/>
            </div>
        </div>
       <!-- <div class="layui-form-item">
            <label class="layui-form-label">角色状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="0" title="可用"<th:if test="${r.status == 0 or r.status==null}">checked</th:if>>
                <input type="radio" name="status" value="1" title="不可用"<if test="${r.status == 1}">checked</if>>

            </div>
        </div>-->

        <!---->
        <div class="layui-form-item" style="display: none;">
            <div class="layui-input-block">
                <a class="layui-btn" id="submitBtn" lay-submit="" lay-filter="submitBtn">提交</a>
            </div>
        </div>
    </form>
</div>

<!---->
<script>
    var $;
    layui.use(['table','form','jquery','layer','upload','element'],function() {
        var table = layui.table, layer = layui.layer,
            form = layui.form,upload = layui.upload,element = layui.element;
        $ = layui.jquery;


        form.on('submit(submitBtn)',function (data) {
            var formData = data.field;
            $.ajax({
                type:'post',
                url:'/system/roc/update',
                data:formData,
                dataType:'json',
                success:function (result) {
                    layer.msg(result.msg);
                    if (result.is){
                        let index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);  //编辑成功后关闭父页面窗口
                        parent.layui.table.reload('roleTable');//根据表格id刷新父页面表格
                    }
                }
            })
        })

    });

    function btnSubmit() {
        $('#submitBtn').click();
    }
</script>

</body>
</html>